package com.ai.entity.network;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;

/**
 * DS收到L2发送的电文内容
 * @Author jiaok
 * @Date 2023-06-20 10:48
 */
@Data
public class L2ToDsSysMessage implements Serializable {
    @ApiModelProperty(value = "电文长度，固定值256")
    private String length;

    @ApiModelProperty(value = "电文号，固定值SIDS01")
    private String teleNo;
    @ApiModelProperty("钢卷号")
    private String coilNo;
    @ApiModelProperty("长度")
    private BigDecimal lengthMm;
    @ApiModelProperty("宽度")
    private BigDecimal width;
    @ApiModelProperty("厚度")
    private BigDecimal thickness;
    @ApiModelProperty("出钢记号")
    private String steelGrade;
    @ApiModelProperty("分选度")
    private String sortingGrade;
    @ApiModelProperty("生产合同号")
    private String workOrderNo;
    @ApiModelProperty("钢种牌号")
    private String orderQuality;

    @ApiModelProperty("最终用途")
    private String finalUse;

    @ApiModelProperty("最终用户代码")
    private String finalUser;

    @ApiModelProperty("过渡卷标志")
    private String dummy;
    @ApiModelProperty("表面结构")
    private String surfStrucCode;

    @ApiModelProperty("后处理方式")
    private String postProc;
    @ApiModelProperty("预留字段")
    private String spare;

    @ApiModelProperty("信号来源")
    private String clientIp;

    @ApiModelProperty("端口")
    private Integer sourcePort;

    @ApiModelProperty("netty客户端code")
    private String nettyCode;
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    @Override
    public boolean equals(Object o) {
        if (o == null){
            return false;
        }
        L2ToDsSysMessage that = (L2ToDsSysMessage) o;
        that.setLengthMm(that.getLengthMm().setScale(3, RoundingMode.HALF_UP));
        that.setWidth(that.getWidth().setScale(3, RoundingMode.HALF_UP));
        that.setThickness(that.getThickness().setScale(3, RoundingMode.HALF_UP));
        return coilNo.equals(that.coilNo) && lengthMm.equals(that.lengthMm) && width.equals(that.width) && thickness.equals(that.thickness) && steelGrade.equals(that.steelGrade) && sortingGrade.equals(that.sortingGrade) && workOrderNo.equals(that.workOrderNo) && orderQuality.equals(that.orderQuality) && finalUse.equals(that.finalUse) && finalUser.equals(that.finalUser) && dummy.equals(that.dummy) && surfStrucCode.equals(that.surfStrucCode) && postProc.equals(that.postProc);
    }

}
